﻿using System;
using System.Collections.Generic;
using System.Linq;
using System.Text;
using System.Windows.Forms;

namespace FezLogForSns
{
    class AppUtil
    {
        /// <summary>
        /// 文字列が有効な色コードか返す
        /// </summary>
        /// <param name="code"></param>
        /// <returns></returns>
        public static bool isValidColorCode(string code)
        {
            if (code.Length != 6) return false;

            try{
                int codeNum = Convert.ToInt32(code, 16);
                string codeRe = Convert.ToString(codeNum, 16).PadLeft(6, '0');
                return codeRe.ToUpper() == code.ToUpper();
            }catch(Exception){
                return false;
            }
        }

        /// <summary>
        /// エラー系ダイヤログを表示
        /// </summary>
        /// <param name="msg"></param>
        /// <param name="title"></param>
        public static void showMsgWarning(string msg, string title="")
        {
            MessageBox.Show(msg, title, MessageBoxButtons.OK, MessageBoxIcon.Error);
        }

        /// <summary>
        /// 正常系ダイヤログを表示
        /// </summary>
        /// <param name="msg"></param>
        /// <param name="title"></param>
        public static void showMsgInfo(string msg, string title = "")
        {
            MessageBox.Show(msg, title, MessageBoxButtons.OK, MessageBoxIcon.Information);
        }

        /// <summary>
        /// OKとキャンセルのダイヤログを表示
        /// </summary>
        /// <param name="Message"></param>
        /// <returns></returns>
        public static DialogResult showOkCancelDlg(string message, string title="")
        {
            return MessageBox.Show(message, title, MessageBoxButtons.OKCancel);
        }

        /// <summary>
        /// バージョン情報を表示
        /// </summary>
        /// <returns></returns>
        public static DialogResult showAboutDlg()
        {
            System.Diagnostics.FileVersionInfo ver =
                System.Diagnostics.FileVersionInfo.GetVersionInfo(
                    System.Reflection.Assembly.GetExecutingAssembly().Location
                );

            return MessageBox.Show("FEZ LogConverter For SNS\n\nVersion " + ver.ProductVersion, "このソフトウェアについて");
        }
    }
}
